package com.example.gpstracking;



import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;

import android.net.wifi.ScanResult;
import android.os.Environment;

public class WriteData {

	List<ScanResult> list;
	
	public WriteData(List<ScanResult> list){
		this.list = list;
	}
	
	
	public boolean writeData(){
	String filename = "asdffilename.txt";
	File file = new File(Environment.getExternalStorageDirectory(), filename);
	FileOutputStream fos = null;
	PrintWriter writer = new PrintWriter(new BufferedOutputStream(fos));
	
//	byte[] data = new String("data to write to file").getBytes();
	try {
	    
		fos = new FileOutputStream(file);
	    Iterator iter = list.iterator();
		while (iter.hasNext()){
			ScanResult result = (ScanResult) iter.next();
			CharSequence myseq = String.valueOf(result);
		writer.append(myseq);
		}
	   
//	    fos.write("adsf");
//	    fos.flush();
//	    fos.close();
	    
	
		 writer.flush();
		writer.close();
	    return true;
	    
	} catch (Exception e) {
	    return false;
	
	   
		
		
	}
	
	}
}
